package com.bestcem.xm.user.dao.mapper;

import com.bestcem.xm.user.entity.mysql.UserUserRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserUserRoleMapper {

    int deleteByPrimaryKey(String userRoleId);

    int insertSelective(UserUserRole userUserRole);

    int insertUserRoleList(List<UserUserRole> userRoles);

    UserUserRole selectByPrimaryKey(String userRoleId);

    int updateByPrimaryKeySelective(UserUserRole userUserRole);

    /**
     * 根据条件查询用户与角色的关联关系
     *
     * @param userUserRole
     * @return
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @version v1.0
     * @date 2022/03/04 16:00
     */
    List<UserUserRole> selectBySelective(UserUserRole userUserRole);

    /**
     * 根据userId删除用户与角色的关联关系
     *
     * @param userId
     * @return com.bestcem.xm.util.ServiceResult<java.lang.Object>
     * @author panyun <yun.pan@idiaoyan.com>
     * @date 2022/3/9 10:37
     */
    int deleteByUserId(String userId);

    /**
     * 根据roleIdList获取userIdList
     *
     * @param roleIdsList
     * @return java.util.List<java.lang.String>
     * @author panyun <yun.pan@idiaoyan.com>
     * @date 2022/3/14 17:24
     */
    List<String> listByRoleIds(List<String> roleIdsList);

    /**
     * 删除指定角色下某一批用户信息
     *
     * @param orgId   公司id
     * @param roleId  角色id
     * @param userIds 用户id列表
     * @return java.lang.Integer
     * @author cuiqiongyu <qiongyu.cui@idiaoyan.cn>
     * @date 2022/03/17 13:19
     */
    Integer deleteByRoleIdAndUserIds(@Param("orgId") String orgId, @Param("roleId") String roleId, @Param("userIds") List<String> userIds);

    /**
     * 根据userId获取角色id列表
     *
     * @param userId
     * @return
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/03/18 16:04
     */
    List<String> listRoleIdByUserId(String userId);

    /**
     * 根据roleId删除
     *
     * @param roleId
     * @return java.lang.Integer
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/05/10 16:53
     */
    Integer deleteByRoleId(String roleId);


    /**
     * 根据roleId集合删除
     *
     * @param roleIdList
     * @return java.lang.Integer
     * @author Linzhijian <zhijian.lin@idiaoyan.com>
     * @date 2022/05/10 16:53
     */
    Integer deleteByRoleIdList(String userId, List<String> roleIdList);
}